package common.harvin.potocol;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;


public final class Request implements Serializable {
	//the type of the request command
	private Command command;
	//the number of the sender.
	private String sender;
	//the number of the receiver
	private String receiver;
	//the data of the request,if there isn't any data,remain null.
	private HashMap<String, String> data = new HashMap<String, String>();
	//the date time of request to be sent.
	private Date send_Date;

	public Request() {
		this.setSend_Date();
	}

	/**
	 * this function will clear the data in data field,
	 * the command,receiver,
	 * but reset the send_Date
	 */
	public void reset() {
		this.data.clear();
		this.command = null;
		this.receiver = null;
		this.send_Date = new Date();
	}

	public Command getCommand() {
		return command;
	}

	public void setCommand(Command command) {
		this.command = command;
	}

	public String getSender() {
		return sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public String getData(String key) {
		return data.get(key);
	}

	public void addData(String key, String value) {
		this.data.put(key, value);
	}

	public Date getSend_Date() {
		return send_Date;
	}

	private void setSend_Date() {
		this.send_Date = new Date();
		System.out.println(send_Date);
	}
}
